package com.yjx.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yjx.vo.Owner;
import com.yjx.service.OwnerService;
import com.yjx.mapper.OwnerMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 10657
* @description 针对表【owner】的数据库操作Service实现
* @createDate 2023-05-10 22:20:21
*/
@Service
public class OwnerServiceImpl extends ServiceImpl<OwnerMapper, Owner>
    implements OwnerService{

    @Resource
    private OwnerMapper ownerMapper;
    @Override
    public Owner queryOwnerByName(String userName) {
        return ownerMapper.queryOwnerByName(userName);
    }

    @Override
    public PageInfo<Owner> findOwnerAll(int page, int limit, Owner owner) {
        PageHelper.startPage(page,limit);
        List<Owner> list = ownerMapper.queryOwnerAll(owner);
        PageInfo<Owner> pageInfo =new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public IPage<Owner> findListByPage(Integer page, Integer pageCount){
        IPage<Owner> wherePage = new Page<>(page, pageCount);
        Owner where = new Owner();

        return   baseMapper.selectPage(wherePage, Wrappers.query(where));
    }


    @Override
    public int add(Owner owner){
        return baseMapper.insert(owner);
    }

    @Override
    public int delete(Long id){
        return baseMapper.deleteById(id);
    }

    @Override
    public int updateData(Owner owner){
        return baseMapper.updateById(owner);
    }

    @Override
    public Owner findById(Long id){
        return  baseMapper.selectById(id);
    }

    @Override
    public void deleteOwnerUserByUserName(String username) {
        ownerMapper.deleteOwnerUserByUserName(username);
    }

    @Override
    public Owner queryOwnerById(long parseLong) {
        return ownerMapper.queryOwnerById(parseLong);
    }
}






